package com.ruoyi.expensereimbursement.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.expensereimbursement.domain.ReimbursementDaily;
import com.ruoyi.expensereimbursement.service.IReimbursementDailyService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 日常报销Controller
 * 
 * @author ruoyi
 * @date 2024-09-25
 */
@RestController
@RequestMapping("/dailyreimbursement")
public class ReimbursementDailyController extends BaseController
{
    @Autowired
    private IReimbursementDailyService reimbursementDailyService;

    /**
     * 查询日常报销列表
     */
    @RequiresPermissions("expensereimbursement:dailyreimbursement:list")
    @GetMapping("/list")
    public TableDataInfo list(ReimbursementDaily reimbursementDaily)
    {
        startPage();
        List<ReimbursementDaily> list = reimbursementDailyService.selectReimbursementDailyList(reimbursementDaily);
        return getDataTable(list);
    }

    /**
     * 导出日常报销列表
     */
    @RequiresPermissions("expensereimbursement:dailyreimbursement:export")
    @Log(title = "日常报销", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReimbursementDaily reimbursementDaily)
    {
        List<ReimbursementDaily> list = reimbursementDailyService.selectReimbursementDailyList(reimbursementDaily);
        ExcelUtil<ReimbursementDaily> util = new ExcelUtil<ReimbursementDaily>(ReimbursementDaily.class);
        util.exportExcel(response, list, "日常报销数据");
    }

    /**
     * 获取日常报销详细信息
     */
    @RequiresPermissions("expensereimbursement:dailyreimbursement:query")
    @GetMapping(value = "/{reimbursementId}")
    public AjaxResult getInfo(@PathVariable("reimbursementId") Long reimbursementId)
    {
        return success(reimbursementDailyService.selectReimbursementDailyByReimbursementId(reimbursementId));
    }

    /**
     * 新增日常报销
     */
    @RequiresPermissions("expensereimbursement:dailyreimbursement:add")
    @Log(title = "日常报销", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReimbursementDaily reimbursementDaily)
    {
        return toAjax(reimbursementDailyService.insertReimbursementDaily(reimbursementDaily));
    }

    /**
     * 修改日常报销
     */
    @RequiresPermissions("expensereimbursement:dailyreimbursement:edit")
    @Log(title = "日常报销", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReimbursementDaily reimbursementDaily)
    {
        return toAjax(reimbursementDailyService.updateReimbursementDaily(reimbursementDaily));
    }

    /**
     * 删除日常报销
     */
    @RequiresPermissions("expensereimbursement:dailyreimbursement:remove")
    @Log(title = "日常报销", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reimbursementIds}")
    public AjaxResult remove(@PathVariable Long[] reimbursementIds)
    {
        return toAjax(reimbursementDailyService.deleteReimbursementDailyByReimbursementIds(reimbursementIds));
    }
}
